Contents | Index | < Browse | Browse >

LETTERstrtokULETTER Splits a string into pieces.

Overview
#include <string.h>

r = strtok(s,delimiters);

char *r;
char *s;
const char *delimiters;

Portability
ANSI

Description
Splits up the string "s" into single pieces whose length is determined by the "delimeters" string. At the first call to this function the first substring is returned, which is the original string until the first occurance of one of the characters in "delimeters".

At each subsequent call "s" must be NULL. This returns the next substring. You can continue this until the string has been completely split.

Note
Between the calls to this function the string must not be modified. Also it is not allowed to call strtok for a string "t" between two calls for a string "s" (which can be hard to check if you're calling many subroutines).

Returns
A pointer to a substring of "s" or NULL if there's no substring left.